package cn.muqingfeng.api.to;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import cn.muqingfeng.api.Api;

import com.google.gson.annotations.SerializedName;

/**
 * 普通列表
 * 
 * @author Administrator
 * 
 */
public class ArticleTO implements Parcelable {
	@SerializedName("tid")
	private String id;

	@SerializedName("subject")
	private String title;

	@SerializedName("authorid")
	private String authorId;

	@SerializedName("author")
	private String author;

	@SerializedName("attachment_url")
	private String cover;

	@SerializedName("dbdateline")
	private long publishTime;

	@SerializedName("replies")
	private int replyCount;

	public ArticleTO() {
	}

	public ArticleTO(Parcel source) {
		this.id = source.readString();
		this.title = source.readString();
		this.authorId = source.readString();
		this.author = source.readString();
		this.cover = source.readString();
		this.publishTime = source.readLong();
		this.replyCount = source.readInt();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(id);
		dest.writeString(title);
		dest.writeString(authorId);
		dest.writeString(author);
		dest.writeString(cover);
		dest.writeLong(publishTime);
		dest.writeInt(replyCount);
	}

	public static final Creator<ArticleTO> CREATOR = new Creator<ArticleTO>() {

		@Override
		public ArticleTO[] newArray(int size) {
			return new ArticleTO[size];
		}

		@Override
		public ArticleTO createFromParcel(Parcel source) {
			return new ArticleTO(source);
		}
	};

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthorId() {
		return authorId;
	}

	public void setAuthorId(String authorId) {
		this.authorId = authorId;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getCover() {
		if (TextUtils.isEmpty(cover)) {
			return null;
		} else {
			if (cover.startsWith("http://") || cover.startsWith("https://")) {
				return cover;
			} else {
				return Api.IMAGE_HOST + cover;
			}
		}
	}

	public void setCover(String cover) {
		this.cover = cover;
	}

	public long getPublishTime() {
		return publishTime;
	}

	public void setPublishTime(long publishTime) {
		this.publishTime = publishTime;
	}

	public int getReplyCount() {
		return replyCount;
	}

	public void setReplyCount(int replyCount) {
		this.replyCount = replyCount;
	}

}
